<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>批量添加点</title>
    <!-- 加载jquery -->
    <script type="text/javascript" src="../../js/jquery-3.1.1.js"></script>
    <!-- 加载百度地图接口 -->
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=GXCSQBVhF8oZlzjfXCmDB5oLrG7ejbYF"></script>
</head>
<body>
<!-- 为ECharts准备一个具备大小（宽高）的Dom -->
<div id="main" style="height:400px"></div>
<button onclick="" value="加载数据"/>
<script>
    // 创建一个map对象，指定div
    var map = new BMap.Map("main");
    // 设置地图当前坐标
    map.centerAndZoom(new BMap.Point(87.60052, 43.81248), 8);
    map.enableScrollWheelZoom(true);

    // 画圆
    var opt ={fillColor:"green", strokeWeight: 1.2 ,fillOpacity: 0.2, strokeOpacity: 0.5};
    var mapCircle = new BMap.Circle(new BMap.Point(87.60052, 43.81248),8000,opt);
    mapCircle.addEventListener("click", function(e){
        alert("圆的点击事件");
    });
    map.addOverlay(mapCircle);

    // 创建图标
    var icon = new BMap.Icon("../../images/circle_red_5.png", new BMap.Size(5, 5));

    var markers = new Array();

    var start_time = new Date();
    console.log("开始加载数据：" + start_time.toLocaleTimeString());

    var points = [{lng:87.66137558,lat:43.96908771},
        {lng:87.66136688,lat:43.96909208},
        {lng:87.66136661,lat:43.96908557},
        {lng:87.66136987,lat:43.96909261},
        {lng:87.66105613,lat:43.96968853},
        {lng:87.66137421,lat:43.96909395},
        {lng:87.66137259,lat:43.96908555},
        {lng:87.66137775,lat:43.96908716},
        {lng:87.66136987,lat:43.9690918 },
        {lng:87.66137693,lat:43.96909367},
        {lng:87.66137394,lat:43.96909205},
        {lng:87.66106102,lat:43.96968498},
        {lng:87.66136797,lat:43.96908882},
        {lng:87.66137666,lat:43.96909123},
        {lng:87.66137041,lat:43.96909261},
        {lng:87.66106075,lat:43.96968064},
        {lng:87.6613696,lat:43.96908882 },
        {lng:87.6613753,lat:43.96909096 },
        {lng:87.66136987,lat:43.96909017},
        {lng:87.6613753,lat:43.96909096 },
        {lng:87.6613753,lat:43.96909313 },
        {lng:87.66137177,lat:43.96908637}];

    //console.log(points);
    //alert(points.length);
    //points = JSON.parse(points);
    //alert(points[0].lng);

    for(var i=0; i<points.length; i++){
        //console.log("[" + points[i].lng + ", " + points[i].lng + "]");
        markers[i] = new BMap.Marker(new BMap.Point(points[i].lng, points[i].lat),{
            icon: icon,
            title: "[" + points[i].lng + ", " + points[i].lat + "]"
        });
        console.log("[" + points[i].lng + ", " + points[i].lat + "]");
        map.addOverlay(markers[i]);
    }

    var end_time = new Date();
    console.log("加载完成：" + end_time.toLocaleTimeString());

</script>

</body>
</html>